<!--
- Author:  LiShibin.
- Date:    2017/7/14.
- File:    detail.vue.
-->
<template>
  <div class=" pb120">
    <div class="Web_Box">

      <!--视频Start-->
      <div class="video_box" style="margin-top:0;">
        <div class="sale_tit f-cb" style="">
          <span class="panic" style="float: none">{{video_info.title}}</span>
        </div>
        <div class="video_block" style="margin: 0 auto; text-align: center;padding: 0.5rem" v-html="resetIframWH($utils.HTMLDecode(video_info.video_html))"></div>
      </div>
      <!--视频Start-->
      <div class=" times">发布时间：{{video_info.addtime | timestampToDate}}</div>
    </div>
    <footer-tab current="video-list"></footer-tab>
  </div>
</template>

<script>
  let bodyClass = document.body.className

  export default{
    beforeRouteEnter (to, from, next) {
      document.body.className = 'bg-white'
      next()
    },
    beforeRouteLeave  (to, from, next) {
      document.body.className = bodyClass
      next()
    },
    data() {
      return {
        video_info: {},
        videoId: this.$route.params.id
      }
    },
    components: {
    },
    created() {
      this.getVideoInfo(this.videoId)
    },
    methods: {
      // 去除iframe字符串的宽高
      resetIframWH(html) {
        html = html.replace(/height=\d+/g, '')
        html = html.replace(/width=\d+/g, 'width="100%"')
        return html
      },
      getVideoInfo: function (vid) {
        this.$request.getVideoDetail(vid).then(data => {
          this.video_info = data
          let title = data.title
          let imgSrc = this.$config.website + this.$config.goodsImgSrc + data.img_url
          console.log('share', window.location.href, title, imgSrc)
          this.$native.weixinShare(window.location.href, title, imgSrc)
        }).catch(e => {
          this.$toast('获取视频详情失败:' + e.msg)
        })
      }
    }
  }
</script>
<style>

</style>